package com.srv.util;


public class SqlBuilder {
	
	public static void builderUserDetailSql(){
		StringBuilder buf = new StringBuilder();
		for(int i = 0; i < 100; i++){
			buf.append("CREATE TABLE `USER_DETAIL_").
			append(StringUtil.appendZore(i, 2)).append("`( ").append("\n");
			buf.append("`PID` BIGINT(16) NOT NULL,").append("\n");
			buf.append("`SEX` INT(2) DEFAULT 0, ").append("\n");
			buf.append("`CREATE_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,").append("\n");
			buf.append("`BIRTHDAY` TIMESTAMP NULL DEFAULT NULL, ").append("\n");
			buf.append("`CITY` VARCHAR(64), ").append("\n");
			buf.append("`LASTLOGIN_TIME` TIMESTAMP NULL DEFAULT NULL, ").append("\n");
			buf.append("`ISDEL` INT(2) DEFAULT 0 , ").append("\n");
			buf.append("`UPDATE_TIME`  TIMESTAMP NULL DEFAULT NULL,").append("\n");
			buf.append("PRIMARY KEY (`PID`)").append("\n");
			buf.append(" )  ENGINE=MYISAM CHARSET=utf8;").append("\n");
			buf.append("\n");
		}
		System.out.println(buf.toString());
	}
	
	public static void builderTravelSql(){
		StringBuilder buf = new StringBuilder();
		for(int i = 0; i < 100; i++){
			buf.append("CREATE TABLE `TRAVEL_").
			append(StringUtil.appendZore(i, 2)).append("`( ").append("\n");
			buf.append("`PID` BIGINT(16) NOT NULL,").append("\n");
			buf.append("`TRAVEL_ID` VARCHAR(64) NOT NULL, ").append("\n");
			buf.append("`TITLE` VARCHAR(64),").append("\n");
			buf.append("`STATUS` INT(2) NULL DEFAULT 0,").append("\n");
			buf.append("`FINISH_TIME` TIMESTAMP NULL DEFAULT NULL,").append("\n");
			buf.append("`FAVOR_NUM` BIGINT(16) NULL DEFAULT 0,").append("\n");
			buf.append("`DOWNLOAD_NUM` BIGINT(16) NULL DEFAULT 0,").append("\n");
			buf.append("`REPUB_NUM` BIGINT(16) NULL DEFAULT 0,").append("\n");
			buf.append("`CREATE_TIME`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,").append("\n");
			buf.append("`ISDEL` INT(2) DEFAULT 0 , ").append("\n");
			buf.append("`UPDATE_TIME`  TIMESTAMP NULL DEFAULT NULL,").append("\n");
			buf.append("PRIMARY KEY (`TRAVEL_ID`),").append("\n");
			buf.append("KEY `IDX_TRAVEL_").append(StringUtil.appendZore(i, 2)).append("_PID` USING BTREE (`PID`),").append("\n");
			buf.append("KEY `IDX_TRAVEL_").append(StringUtil.appendZore(i, 2)).append("_TITLE` USING BTREE (`TITLE`)").append("\n");
			buf.append(" )  ENGINE=MYISAM CHARSET=utf8;").append("\n");
			buf.append("\n");
		}
		System.out.println(buf.toString());
	}
	
	public static void builderNodeSql(){
		StringBuilder buf = new StringBuilder();
		for(int i = 0; i < 100; i++){
			buf.append("CREATE TABLE `NODE_").
			append(StringUtil.appendZore(i, 2)).append("`( ").append("\n");
			buf.append("`PID` BIGINT(16) NOT NULL,").append("\n");
			buf.append("`TRAVEL_ID` varchar(64) NOT NULL, ").append("\n");
			buf.append("`NODE_ID` varchar(64) NOT NULL,").append("\n");
			buf.append("`FAVOR_NUM` bigint(16) DEFAULT '0',").append("\n");
			buf.append("`DOWNLOAD_NUM` bigint(16) DEFAULT '0',").append("\n");
			buf.append("`REPUB_NUM` bigint(16) DEFAULT '0',").append("\n");
			buf.append("`IMG_URI` varchar(256) DEFAULT NULL,").append("\n");
			buf.append("`RECORD_URI` varchar(256) DEFAULT NULL,").append("\n");
			
			buf.append("`IMG_INNER_URI` varchar(1024) DEFAULT NULL,").append("\n");
			buf.append("`RECORD_INNER_URI` varchar(1024) DEFAULT NULL,").append("\n");
			
			buf.append("`CONTEXT` varchar(1024) DEFAULT NULL,").append("\n");
			buf.append("`TAG` varchar(64) DEFAULT NULL,").append("\n");
			buf.append("`LONGITUDE` double DEFAULT '0',").append("\n");
			buf.append("`LATITUDE` double DEFAULT '0',").append("\n");
			buf.append("`CREATE_TIME` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,").append("\n");
			buf.append("`ISDEL` int(2) DEFAULT '0',").append("\n");
			buf.append("`UPDATE_TIME` timestamp NULL DEFAULT NULL,").append("\n");
			buf.append("PRIMARY KEY (`NODE_ID`),").append("\n");
			buf.append("KEY `IDX_NODE_").append(StringUtil.appendZore(i, 2)).append("_PID` (`PID`) USING BTREE,").append("\n");
			buf.append("KEY `IDX_NODE_").append(StringUtil.appendZore(i, 2)).append("_TRAVELID` (`TRAVEL_ID`) USING BTREE,").append("\n");
			buf.append("KEY `IDX_NODE_").append(StringUtil.appendZore(i, 2)).append("_TAG` (`TAG`) USING BTREE,").append("\n");
			buf.append("KEY `IDX_NODE_").append(StringUtil.appendZore(i, 2)).append("_LONGITUDE` (`LONGITUDE`) USING BTREE,").append("\n");
			buf.append("KEY `IDX_NODE_").append(StringUtil.appendZore(i, 2)).append("_LATITUDE` (`LATITUDE`) USING BTREE").append("\n");
			buf.append(" )  ENGINE=MYISAM CHARSET=utf8;").append("\n");
			buf.append("\n");
		}
		System.out.println(buf.toString());
	}
	
	public static void dropNodeTable(){
		StringBuilder buf = new StringBuilder();
		for(int i = 0; i < 100; i++){
			buf.append("DROP TABLE `NODE_").append(StringUtil.appendZore(i, 2)).append("`;");
			buf.append("\n");
		}
		System.out.println(buf.toString());
	}
	
	public static void main(String[] args) {
		SqlBuilder.builderNodeSql();
	}
}
